{include file="common/head"/}
<div class="admin-main layui-anim layui-anim-upbit">
    <fieldset class="layui-elem-field layui-field-title">
        <legend>报单列表</legend>
    </fieldset>
    <div class="demoTable">
        <div class="layui-inline">
            <input class="layui-input" name="key" id="key" placeholder="{:lang('pleaseEnter')}会员手机号">
        </div>
        <button class="layui-btn" id="search" data-type="reload">搜索</button>
        <a href="{:url('baodan_log')}" class="layui-btn">显示全部</a>
      <!----  <button type="button" class="layui-btn layui-btn-danger" id="delAll">批量删除</button>---->
    </div>
    <table class="layui-table" id="list" lay-filter="list"></table>
</div>
<script type="text/html" id="is_lock">
    <input type="checkbox" name="is_lock" value="{{d.bid}}" lay-skin="switch" lay-text="未打款|已打款" lay-filter="is_lock" {{ d.is_lock == 0 ? 'checked' : '' }}>
</script>
<script type="text/html" id="action">

    {{# if(d.is_ok =='2'){ }}
    <a class="layui-btn layui-btn-danger layui-btn-xs" >未能收到货款</a>
    {{# } }}
	{{# if(d.is_ok =='1'){ }}
     <a class="layui-btn layui-btn-xs">已经成功收款</a>
   
    {{# } }}
	 {{# if(d.is_ok =='0'){ }}
     <a lay-event="dakuan" class="layui-btn layui-btn-xs">确认</a>
    <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del">驳回</a>
    {{# } }}
  
</script>
<script type="text/html" id="email">
    {{d.email}}
    {{# if(d.email && d.email_validated=='0'){ }}
    (未验证)
    {{# } }}
</script>
{include file="common/foot"/}
<script>
    layui.use(['table','form'], function() {
        var table = layui.table,form = layui.form, $ = layui.jquery;
        var tableIn = table.render({
            id: 'user',
            elem: '#list',
            url: '{:url("baodan_log")}',
            method: 'post',
            page: true,
            cols: [[
               // {checkbox:true,fixed: true},
                {field: 'bid', title: '{:lang("编号")}', width: 60, fixed: true},
                {field: 'beizhu', align: 'center',title: '会员手机号', width: 220},
				
               // {field: 'bank_name', title: '开户银行', width: 140},
              //  {field: 'bank_card', title: '开户帐号', width: 200},
               {field: 'nick_name', align: 'center',title: '会员姓名', width: 200},
			//	{field: 'bank_dizhi', title: '开户地址', width: 250},
				{field: 'id_card', align: 'center',title: '身份证', width: 200},
				{field: 'address', align: 'center',title: '联系地址', width: 200},
				{field: 'num', align: 'center',title: '使用报单币', width: 200},
				{field: 'mobile', align: 'center',title: '报单中心', width: 200},
				{field: 'time', align: 'center',title: '报单时间', width: 250},
				// {field: 'reg_time', title: '注册时间', width: 150},
               // {field: 'is_ok', align: 'center',title: '提现状态', width: 120,toolbar: '#is_lock'},
               
              {width: 160, align: 'center', toolbar: '#action'}
            ]],
            limit: 20 //每页默认显示的数量
        });
        form.on('switch(is_lock)', function(obj){
            loading =layer.load(1, {shade: [0.1,'#fff']});
            var id = this.value;
            var is_lock = obj.elem.checked===true?0:1;
            $.post('{:url("tixians")}',{'id':id,'is_lock':is_lock},function (res) {
                layer.close(loading);
                if (res.status==1) {
                    tableIn.reload();
                }else{
                    layer.msg(res.msg,{time:1000,icon:2});
                    return false;
                }
            })
        });
        //搜索
        $('#search').on('click', function() {
            var key = $('#key').val();
            if($.trim(key)==='') {
                layer.msg('{:lang("pleaseEnter")}关键字！',{icon:0});
                return;
            }
            tableIn.reload({ page: {page: 1},where: {key: key}});
        });
        table.on('tool(list)', function(obj) {
            var data = obj.data;
            if (obj.event === 'del') {
                layer.confirm('您确定未收到货款吗？', function(index){
                    var loading = layer.load(1, {shade: [0.1, '#fff']});
                    $.post("{:url('bohuibaodan')}",{id:data.bid},function(res){
                        layer.close(loading);
                        if(res.code===1){
                            layer.msg(res.msg,{time:1000,icon:1});
                            tableIn.reload();
                        }else{
                            layer.msg('操作失败！',{time:1000,icon:2});
                        }
                    });
                    layer.close(index);
                });
            }
			  if (obj.event === 'dakuan') {
                layer.confirm('您确定收到货款了吗？', function(index){
                    var loading = layer.load(1, {shade: [0.1, '#fff']});
                    $.post("{:url('baodanok')}",{id:data.bid},function(res){
                        layer.close(loading);
                        if(res.code===1){
                            layer.msg(res.msg,{time:1000,icon:1});
                            tableIn.reload();
                        }else{
                            layer.msg('操作失败！',{time:1000,icon:2});
                        }
                    });
                    layer.close(index);
                });
            }
        });

        $('#delAll').click(function(){
            layer.confirm('确认要删除选中信息吗？', {icon: 3}, function(index) {
                layer.close(index);
                var checkStatus = table.checkStatus('user'); //test即为参数id设定的值
                var ids = [];
                $(checkStatus.data).each(function (i, o) {
                    ids.push(o.id);
                });
                var loading = layer.load(1, {shade: [0.1, '#fff']});
                $.post("{:url('delall')}", {ids: ids}, function (data) {
                    layer.close(loading);
                    if (data.code === 1) {
                        layer.msg(data.msg, {time: 1000, icon: 1});
                        tableIn.reload();
                    } else {
                        layer.msg(data.msg, {time: 1000, icon: 2});
                    }
                });
            });
        })
    });
</script>
</body>
</html>